<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/XGame_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<?php
include("config.php");
if($_SERVER["REQUEST_METHOD"] == "POST")
{
	if((!empty($_POST['login_email'])) && $_POST['login_password'])
	{	
		session_start();		
		$email=addslashes($_POST['login_email']);
		$password=addslashes($_POST['login_password']);
		$sql="SELECT * FROM user WHERE user_email ='$email' and user_password ='$password'";
		$result=mysql_query($sql);
		$row=mysql_fetch_array($result);
		$loginID=$row['user_ID'];
		$count=mysql_num_rows($result);		
		if($count==1)
		{
		
			if($row['is_admin']==1){
				$_SESSION['login_user']=$loginID;
				
				header('Location: AdminMember.php');
			}
			else
			{
				$_SESSION['login_user']=$loginID;
				header("location: Home.php");
			}
			
		}
		else {
			echo "<script type='text/javascript'> alert('Wrong username and/or password')</script>";
		}
	}
	else if ($_POST['email'] && $_POST['password'] && $_POST['username'] && $_POST['Date'] && $_POST['Month'] && $_POST['Year'] && $_POST['address'] && $_POST['contact_number'])
	{
		$email=addslashes($_POST['email']);
		$password=addslashes($_POST['password']);
		$name=addslashes($_POST['username']);
		$day=addslashes($_POST['Date']);
		$month=addslashes($_POST['Month']);
		$year=addslashes($_POST['Year']);
		$address=addslashes($_POST['address']);
		$contact=addslashes($_POST['contact_number']);
		$joindate=date("Y-m-d");
		$date = $year.'-'.$month.'-'.$day;
			
		$sql="INSERT INTO user (user_email, user_name, user_password, user_dob, user_address, user_contact, join_date, is_admin) VALUES ('$email', '$name', '$password', '$date', '$address', '$contact', '$joindate', 0)";
		mysql_query($sql);
		
	}
}
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>XGame</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->

<!-- InstanceEndEditable -->
<link type="text/css" rel="stylesheet" href="CSS/css.css" />
</head>

<body>
<div id="container">

<div id="wrapper">

<div id="banner">
<!-- InstanceBeginEditable name="TopLink" -->
<?php
include('config.php');
if(!empty($_SESSION['login_user'])){
	$login = $_SESSION['login_user'];
	$q = "SELECT user_name FROM user where user_ID = '$login'";
	$result=mysql_query($q);
	$data_fetch=mysql_fetch_array($result);
?>
<ul class="topLink">
<li> Welcome, <a href="UserProfile.php"> <?php echo $data_fetch['user_name']; ?> </a> </li>
<li> <a href="Wishlist.php"> Wishlist </a> &nbsp; | &nbsp;<a href="userShoppingCart.php"> Cart </a> </li>
<li> <a href="Logout.php"> Logout </a> </li>
</ul>
<?php
	}
	else{
?>
<div class="welcome">
<p style="float:right; padding-right:10px"> Welcome: &nbsp; (
<a href="Register.php"> LOGIN</a> |
<a href="Register.php"> REGISTER </a>) </p>
</div>
<?php
	}
?>
<!-- InstanceEndEditable -->

<img src="Assets/XGame.png" alt="XGame" />
</div>

<div id="menu">
<ul class="nav">
<form method="post" action="search_result.php">
<li> <span> <input type="text" placeholder="Search Keyword" name="search" />
&nbsp; <input type="submit" name="Search" value="Search" /> </span>
</li>
</form>
<li> <a href="Home.php"> Home </a> </li>
<li> <a href="ListOfNews.php"> News </a> </li>
<li> <a href="Games.php"> Games </a> </li>
<li> <a href="FAQ.php"> FAQ </a> </li>
<li> <a href="ContactUs.php"> Contact Us </a> </li>
</ul>

</div>

<div id="main">
<!-- InstanceBeginEditable name="Main" -->
<table border="0" width="800px">
<tr>
<td>
<form id="login" name="login" method="POST">
<h2> Login </h2>

<label> Email </label>
<input type="email" name="login_email" />

<label> Password </label>
<input type="password" name="login_password" />

<button type="submit">Log In</button>

</form>
</td>
<td width="5px" style="border-right:2px solid #333;">&nbsp;  </td>
<td width="350px">
<form id="register" name="register" method="POST">
<h2> Create an account </h2>

<label>Email
<span class="small">Add a valid address</span>
</label>
<input type="text" name="email" />

<label>Password
<span class="small">Min. size 6 chars</span>
</label>
<input type="password" name="password" />

<label>Name
<span class="small">Add your name</span>
</label>
<input type="text" name="username" />

<label> Date of Birth
<span class="small">Add your DOB</span>
</label>
<select name="Date" required>
    <option> 1 </option>
    <option> 2 </option>
    <option> 3 </option>
    <option> 4 </option>
    <option> 5 </option>
    <option> 6 </option>
    <option> 7 </option>
    <option> 8 </option>
    <option> 9 </option>
    <option> 10 </option>
    <option> 11 </option>
    <option> 12 </option>
    <option> 13 </option>
    <option> 14 </option>
    <option> 15 </option>
    <option> 16 </option>
    <option> 17 </option>
    <option> 18 </option>
    <option> 19 </option>
    <option> 20 </option>
    <option> 21 </option>
    <option> 22 </option>
    <option> 23 </option>
    <option> 24 </option>
    <option> 25 </option>
    <option> 26 </option>
    <option> 27 </option>
    <option> 28 </option>
    <option> 29 </option>
    <option> 30 </option>
    <option> 31 </option>
    </select> &nbsp;
    
    <select name="Month">
    <option value= "1"> January </option>
    <option value= "2"> February </option>
    <option value= "3"> March </option>
    <option value= "4"> April </option>
    <option value= "5"> May </option>
    <option value= "6"> June </option>
    <option value= "7"> July </option>
    <option value= "8"> August </option>
    <option value= "9"> September </option>
    <option value= "10"> October </option>
    <option value= "11"> November </option>
    <option value= "12"> December </option>
    </select> &nbsp;
    
    <select name="Year">
    <option> 1980 </option>
    <option> 1981 </option>
    <option> 1982 </option>
    <option> 1983 </option>
    <option> 1984 </option>
    <option> 1985 </option>
    <option> 1986 </option>
    <option> 1987 </option>
    <option> 1988 </option>
    <option> 1989 </option>
    <option> 1990 </option>
    <option> 1991 </option>
    <option> 1992 </option>
    <option> 1993 </option>
    <option> 1994 </option>
    <option> 1995 </option>
    <option> 1996 </option>
    <option> 1997 </option>
    <option> 1998 </option>
    <option> 1999 </option>
    <option> 2000 </option>
    <option> 2001 </option>
    <option> 2002 </option>
    <option> 2003 </option>
    <option> 2004 </option>
    <option> 2005 </option>
    <option> 2006 </option>
    <option> 2007 </option>
    <option> 2008 </option>
    <option> 2009 </option>
    <option> 2010 </option>
    <option> 2011 </option>
    <option> 2012 </option>
</select>

<label>Address
<span class="small">Add your address</span>
</label>
<input type="text" name="address" />

<label>Contact Number
<span class="small">Add your contact number</span>
</label>
<input type="text" name="contact_number" />

<button type="submit">Sign-up</button>

</form>
</td>
</tr>
</table>

<!-- InstanceEndEditable -->
</div>

<div id="footer">
<p align="center"> &copy; &nbsp; 2012 XGame </p>
</div>

</div>

</div>

</body>
<!-- InstanceEnd --></html>